As described in WO 2012/044964, yaw, roll and pitch angles of a device in a gravitational reference system may be evaluated using measurements of a magnetometer and other motion sensors (accelerometers, gyroscopes) attached to the device. These methods include:                determining a measured 3D magnetic field, a roll, a pitch and a raw estimate of yaw in the body reference system based on the received measurements,        extracting a local 3D magnetic field from the measured 3D magnetic field, and        calculating yaw angle of the body reference system in the gravitational reference system based on the extracted local 3D magnetic, the roll, the pitch and the raw estimate of yaw using at least two different methods,wherein estimated errors of the roll, the pitch, and the extracted local 3D magnetic field affect an error of the yaw differently for the different methods.        
A rotation matrix corresponding to the yaw, roll and pitch angles may be expressed as a quaternion (conversion between a rotation matrix corresponding to rotations around three orthogonal axes and a quaternion is known). The result of the sensor fusion methods described in WO 2012/044964 may be expressed as a quaternion.
Motion sensors may include gyroscopes or other sensors configured to measure angular velocities. The quaternion result from sensor fusion method (referred to as “fusion quaternion” hereinafter) is the best estimation of rotation angles (yaw, roll and pitch) based on all available sensor data. The sensor orientation (i.e., the output quaternion) may be mapped on a variable such as a position of a cursor on a screen or an image displayed to a user of a gaming system. Therefore, the output quaternion should be as accurate, stable (e.g., varying smoothly rather than “jumpy”) and consistent with all sensor indications as achievable. However, at certain moments, the angle estimations (which may be expressed as the fusion quaternion) do not agree with direct angular velocity measurements and, therefore, are not suitable for direct and indiscriminate use.
When a conflict between the fusion quaternion and the measured angular velocity arises, simple approaches to overcome this conflict are (1) to use the fusion quaternion directly or (2) to use measured angular velocity only.
One problem with the first approach (using the fusion quaternion directly) is that the fusion quaternion is not always continuous due to many reasons, such as magnetic field interference, linear acceleration, accelerometer saturation, etc. Another problem is that a fusion quaternion may keep moving while the device is still, due to delays introduced in the fusion process. Moreover, the fusion quaternion may also move in a direction different from that indicated by the angular velocity, due to delay or adjustment.
The second approach (using only angular velocity) is also problematic. The integration drift over a long period of time may cause a large misalignment between the integrated angular position and the device's true orientation.
Accordingly, it would be desirable to provide apparatuses and methods that advantageously make use of the fusion quaternion while also maintaining compatibility with measured angular velocity and avoid the problems identified above relative to the first and second approaches.